package com.sjtu.vfact.textual.util;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import com.sjtu.vfact.textual.model.TermSet;

public class TextUtil {
	
	public static <E> List<E> intersect(List<E> list1, List<E> list2){
		List<E> l1 = new ArrayList<E>(list1);
		l1.retainAll(list2);
		return l1;
	}
	
	public static <E> Set<E> intersect(Set<E> set1, Set<E> set2){
		Set<E> s1 = new LinkedHashSet<E>(set1);
		s1.retainAll(set2);
		return s1;
	}
	
	public static TermSet intersect(TermSet ts1, TermSet ts2){
		List<String> l1 = TextUtil.<String>intersect(ts1.getTerms(), ts2.getTerms());
		return new TermSet(l1);
	}
	
	public static boolean inRangeOf(int number, int min, int max){
		if(number >= min && number <= max){
			return true;
		}
		return false;
	}
	
}
